package com.example.mapper;

import com.example.pojo.Maintain;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MaintainMapper {
    @Insert("insert into maintain(damage, damage_type, q_date, tnumber, himage, t_date, tname, id_a, fdname, name, fyimage, location, id_f, id_u) values (#{damage}, #{damageType}, #{qDate}, #{tnumber}, #{himage}, #{tDate}, #{tname}, #{idA}, #{fdname}, #{name}, #{fyimage}, #{location}, #{idF}, #{idU})")
    void addServiceApartment(Maintain maintain);

    @Update("update maintain set sfpd=1,pd_id=#{pdId},pname=#{pname},pnumber=#{pnumber} where id=#{id} and id_f=#{idF}")
    void setServiceman(Maintain maintain);

    @Select("select * from maintain where id_u=#{idU} order by t_date desc")
    List<Maintain> getServiceApartmentZK(Integer idU);

    List<Maintain> getServiceApartmentFD(String name,Integer sfpd, Integer idF);

    @Update("update maintain set sfpd=2,sfwc=1 where id=#{id} and id_f=#{idF}")
    void setRepair(Integer id, Integer idF);

    @Select("select pd_id from maintain where id=#{id}")
    Integer getServiceApartment(Integer id);
}
